<!-- pages/camera/camera.vue -->
<template>
	
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		mounted() {
			uni.chooseVideo({
				sourceType: ['camera'],
				camera: 'front',
				success: (res) =>  {
					this.getVideoInfo(res)
				}
			});
		},
		methods: {
			getVideoInfo(res){
				const videoContext = uni.createVideoContext('myVideo');
				const randomTime = Math.random() * res.duration
				videoContext.seek(randomTime); // 定位到视频的某一帧
				    uni.canvasToTempFilePath({
						 width: res.width,
						  height: res.height,
						  destWidth: res.width,
						  destHeight: res.height,
				        canvasId: 'myCanvas',
				        success: function (res) {
				            console.log(res.tempFilePath,'res.width'); // 图片的临时路径
				        }
				    });
				// this.$emit('videoSuccessInfo', res)
			},
			
		}
	}
</script>